﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Runtime.Serialization;

namespace CMD.BAL.CAT
{
   [DataContractAttribute]
   public class MedioColocacion
   {
       [DataMemberAttribute(EmitDefaultValue = false)]
       public string idMedColocacion;
       [DataMemberAttribute(EmitDefaultValue = false)]
       public string dscMedColocacion;
       public static DataTable GetData()
       {
            DataTable dt;
            //ejecutar store
            dt = CMD_WEB.DAL.SrvDB.ExecuteQuery("exec SP_CMD_CAT_SEL_MEDIOCOLOCACION");
            return dt;
       }
       public static List<MedioColocacion> GetDataMedioColocacion()
       {
           try
           {
               DataTable dt;
               dt = MedioColocacion.GetData();
               if (dt.Rows.Count == 0)
               {
                   return null;
               }
               else
               {
                   List<MedioColocacion> list = dt.AsEnumerable().Select(
                   row => new MedioColocacion
                   {
                       idMedColocacion = String.IsNullOrEmpty(row.Field<string>("ID_MED_COLOCACION").ToString())
                       ? ""
                       : row.Field<string>("ID_MED_COLOCACION").ToString(),
                       dscMedColocacion = String.IsNullOrEmpty(row.Field<string>("DSC_MED_COLOCACION"))
                       ? ""
                       : row.Field<string>("DSC_MED_COLOCACION"),
                   }
                   ).ToList();
                   return list;
           }
           }
           catch (Exception ex)
           {

               throw ex;
           }
       }
       public MedioColocacion()
       {
           idMedColocacion = "";
           dscMedColocacion = "";
       }
       //public MedioColocacion(string dscMedColocacion)
       public MedioColocacion(string idMedColocacion, string dscMedColocacion)
       {
           this.idMedColocacion = idMedColocacion;
           this.dscMedColocacion = dscMedColocacion;
       }
   }
}
